package com.example.societiesSystem.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.societiesSystem.common.R;
import com.example.societiesSystem.dto.ActivityLogsAddDTO;
import com.example.societiesSystem.dto.ApplyLogsAddDTO;
import com.example.societiesSystem.entity.ApplyLogs;
import com.example.societiesSystem.service.IApplyLogsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 入团申请信息表 前端控制器
 * </p>
 *
 * @author 周欢
 * @since 2025-05-27
 */
@Api(tags = "入团申请信息表 前端控制器")
@CrossOrigin
@RestController
@RequestMapping("/applyLogs")
public class ApplyLogsController {

    
    @Resource
    private IApplyLogsService applyLogsService;

    @ApiOperation(value = "入团申请信息查询")
    @GetMapping("/page")
    public R pageAll(@RequestParam("pageIndex") Long pageIndex
            , @RequestParam("pageSize") Long pageSize
            , @RequestParam(value = "token" ,required = false) String token
            , @RequestParam(value = "teamName", required = false) String teamName
            , @RequestParam(value = "userName", required = false) String userName)
    {
        return R.data(applyLogsService.pageAll(pageIndex,pageSize,token,teamName,userName));
    }


    @ApiOperation(value = "入团申请信息添加")
    @PostMapping("/add")
    public R add(@RequestBody ApplyLogsAddDTO applyLogsAddDTO) {
        return R.data(applyLogsService.add(applyLogsAddDTO));
    }

    @ApiOperation(value = "根据userId查询社团活动信息")
    @GetMapping("/man")
    public R man(@RequestParam("manId") Long manId) {
        return R.data(applyLogsService.getBaseMapper().selectList(new LambdaQueryWrapper<ApplyLogs>()
                .eq(ApplyLogs::getUserId,manId)));
    }

    @ApiOperation(value = "入团申请信息修改")
    @PostMapping("/upd")
    public R upd(@RequestBody ApplyLogs applyLogs) {
        return R.data(applyLogsService.updateById(applyLogs));
    }

    @ApiOperation(value = "入团申请信息删除")
    @PostMapping("/del")
    public R del(@RequestBody ApplyLogs applyLogs) {
        return R.data(applyLogsService.removeById(applyLogs));
    }
}
